<template>
	<view class="content">
		<view class="rich-text">
			<rich-text :nodes="html"></rich-text>
		</view>
		<view class="bottom-safe-area"></view>
	
		<common-drag />
	</view>
</template>
<script>
	export default {
		data() {
			return {
				html:''
			}
		},
		onLoad(options) {
			//detect membership or card
			if(options.state==2){
				//会员
				uni.setNavigationBarTitle({
					title:'会员卡权益'
				})
				this.getHtmlRequest(options.id);
			}else if(options.state==1){
				//月卡
				uni.setNavigationBarTitle({
					title:'月卡权益'
				})
				this.getCardHtmlRequest(options.id);
			}else if(options.state==3){
				//老的首页的用户协议
				this.getOldIndexProtocolRequest();
			};
		},
		methods: {
			//member
			getHtmlRequest(id){
				this.$u.api.getHtml({
					
					cal_id:id,
				}).then(res=>{
					if(res.result_code=='300'){
						
						
						// #ifdef	MP-WEIXIN
						this.html=res.data.agreement;
						// #endif
						
						
						// #ifdef	MP-ALIPAY
						this.html=this.$parseHtml(res.data.agreement);
						// #endif
					}else{
						this.$utils.toast(res.msg);
					};
				}).catch(()=>{
				
				});
			},
			//card
			getCardHtmlRequest(id){
				this.$u.api.getCardHtml({
					
					cal_id:id,
				}).then(res=>{
					if(res.result_code=='300'){
						
						//*微信
						// #ifdef	MP-WEIXIN
						this.html=res.data.agreement;
						// #endif
						
						// #ifdef	MP-ALIPAY
						this.html=this.$parseHtml(res.data.agreement);
						// #endif
					}else{
						this.$utils.toast(res.msg);
					};
				}).catch(()=>{
				
				});
			},
			//老首页的用户协议
			getOldIndexProtocolRequest(){
				this.$u.api.getUserAgreement().then(res=>{
					
					//*微信
					// #ifdef	MP-WEIXIN
					this.html=res.data.agreement;
					// #endif
					
					
					// #ifdef	MP-ALIPAY
					this.html=this.$parseHtml(res.data.agreement);
					// #endif
					
				}).catch(()=>{
				
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding:30rpx;
	}
</style>

